<template>
  <div class="citySelect">
    <van-tree-select
      :items="items"
      :active-id.sync="activeId"
      :main-active-index.sync="activeIndex"
      @click-item="handleItem"
    />
  </div>
</template>

<style lang="scss" scoped>
.citySelect {
  height: 100vh;
  .van-tree-select {
    height: 100vh !important;
    font-size: 18px;
  }
  .van-tree-select__item--active {
    color: #1989fa;
  }
  .van-sidebar-item {
    font-size: 18px;
  }
  .van-sidebar-item--select::before {
    background-color: #1989fa;
  }
}
</style>


<script>
import { getDatalistForTree, getuserRelManyBiz } from '@/utils/api'
import { analyze } from 'eslint-scope'
import {isLinAn} from '@/utils/isLinAn'
export default {
  data() {
    return {
      items: [
        {
          // 导航名称
          text: '惠州市',
          // 导航名称右上角徽标，2.5.6 版本开始支持
          // badge: 3,
          // 是否在导航名称右上角显示小红点
          // dot: true,
          // 导航节点额外类名
          className: 'my-class',
          // 该导航下所有的可选项
          children: [],
        },
      ],
      activeId: 0,
      activeIndex: 0,
    }
  },
  methods: {
    getCityOpenDataView: async function () {
      const res = await getDatalistForTree('330000000000')
      res.data.data.map((item, index) => {
        let obj = {
          text: item.cityname,
          id: index + 1,
          citycode: item.citycode,
        }
        this.items[0].children.push(obj)
      })
    },
    handleItem(data) {
      console.log(data.text)
      window.localStorage.setItem('citycode', data.citycode)
      this.$router.push({
        path: '/FeatureList',
      })
    },
  },
  mounted() {
    this.getCityOpenDataView()
  },
}
</script>
